package com.itheima.homework.Two;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Demo {

    public static void main(String[] args) {

        List<Student> list = new ArrayList<>();

        Student stu1 = new Student("张三",18,55.0);
        Student stu2 = new Student("李四",25,57.2);
        Student stu3 = new Student("王五",23,60.0);
        Student stu4 = new Student("老六",28,70.0);
        Student stu5 = new Student("洪七",13,65.3);

        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        list.add(stu4);
        list.add(stu5);

        double max = 0;
        double min = 100;
        double sum = 0;



        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));

            if(max<list.get(i).getScore()){
                max = list.get(i).getScore();
            }
            if(min>list.get(i).getScore()){
                min = list.get(i).getScore();
            }

            sum += list.get(i).getScore();
        }

        BigDecimal b1 = BigDecimal.valueOf(sum);
        BigDecimal b2 = BigDecimal.valueOf(list.size());

        BigDecimal divide = b1.divide(b2);




        System.out.println(max+"\t"+min+"\t"+sum+"\t"+divide);
    }
}
